<?php

/**
 * Created by PhpStorm.
 * User: 汪汪汪
 * Date: 4/4/14
 * Time: 9:29 AM
 */
namespace Api\Model;

use Think\Model;


require_once(VENDOR_PATH . 'IgeTui/IGtPush.php');
require_once(VENDOR_PATH . 'Protobuf/pbmessage.php');
require_once(VENDOR_PATH . 'Exception/RequestException.php');
require_once(VENDOR_PATH . 'IgeTui/IGtReq.php');
require_once(VENDOR_PATH . 'IgeTui/IGtMessage.php');
require_once(VENDOR_PATH . 'IgeTui/IGtAppMessage.php');
require_once(VENDOR_PATH . 'IgeTui/IGtListMessage.php');
require_once(VENDOR_PATH . 'IgeTui/IGtSingleMessage.php');
require_once(VENDOR_PATH . 'IgeTui/IGtAPNPayload.php');
require_once(VENDOR_PATH . 'IgeTui/IGtTarget.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtBaseTemplate.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtLinkTemplate.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtNotificationTemplate.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtTransmissionTemplate.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtNotyPopLoadTemplate.php');
require_once(VENDOR_PATH . 'IgeTui/template/IGtAPNTemplate.php');

/*推送的配置文件*/
define('APPKEY', 'BXNLHSOPnk6ZtM5x7NmjH4');
define('APPID', 't0pWu8QVxoAdKULKQgkUx9');
define('MASTERSECRET', 'kXaFm0DNM36SJlpw7QY057');
define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');

//getUserStatus();

//stoptask();

//setTag();

//getUserTags();

//pushMessageToSingle();

//pushMessageToSingleBatch();

//getPersonaTagsDemo();

//getUserCountByTagsDemo();

//pushMessageToList();

//pushMessageToApp();

//pushAPN();

//pushAPNL();

//getPushMessageResultDemo();


class IgtModel extends Model
{
    public function getPersonaTagsDemo()
    {
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $ret = $igt->getPersonaTags(APPID);
        return $ret;
    }

    public function getUserCountByTagsDemo()
    {
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $tagList = array("金在中", "龙卷风");
        $ret = $igt->getUserCountByTags(APPID, $tagList);
        return $ret;
    }

    public function getPushMessageResultDemo()
    {


//    putenv("gexin_default_domainurl=http://183.129.161.174:8006/apiex.htm");

        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);

        $ret = $igt->getPushResult("OSA-0522_QZ7nHpBlxF6vrxGaLb1FA3");
        return $ret;

        $ret = $igt->queryAppUserDataByDate(APPID, "20140807");
        return $ret;

        $ret = $igt->queryAppPushDataByDate(APPID, "20140807");
        return $ret;
    }

    public function pushAPN()
    {

        //APN简单推送
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $template = new \IGtAPNTemplate();
        $apn = new \IGeTui\IGtAPNPayload();
        $alertmsg = new \IGeTui\SimpleAlertMsg();
        $alertmsg->alertMsg = "";
        $apn->alertMsg = $alertmsg;
//        $apn->badge=2;
        $apn->sound = "";
        $apn->add_customMsg("payload", "payload");
        $apn->contentAvailable = 1;
        $apn->category = "ACTIONABLE";
        $template->set_apnInfo($apn);
        $message = new \IGtSingleMessage();

        //APN高级推送
//        $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
//        $template = new IGtAPNTemplate();
//        $apn = new IGtAPNPayload();
//        $alertmsg=new DictionaryAlertMsg();
//        $alertmsg->body="body";
//        $alertmsg->actionLocKey="ActionLockey";
//        $alertmsg->locKey="LocKey";
//        $alertmsg->locArgs=array("locargs");
//        $alertmsg->launchImage="launchimage";
////        IOS8.2 支持
//        $alertmsg->title="Title";
//        $alertmsg->titleLocKey="TitleLocKey";
//        $alertmsg->titleLocArgs=array("TitleLocArg");
//
//        $apn->alertMsg=$alertmsg;
//        $apn->badge=7;
//        $apn->sound="test1.wav";
//        $apn->add_customMsg("payload","payload");
//        $apn->contentAvailable=1;
//        $apn->category="ACTIONABLE";
//        $template->set_apnInfo($apn);
//        $message = new IGtSingleMessage();

        //PushApn老方式传参
//    $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
//    $template = new IGtAPNTemplate();
//    $template->set_pushInfo("actionLocKey", 6, "body", "", "payload", "locKey", "locArgs", "launchImage",1);
//    $message = new IGtSingleMessage();
////
//    $message->set_data($template);
        $ret = $igt->pushAPNMessageToSingle(APPID, DEVICETOKEN, $message);
        return $ret;
    }

    public function pushAPNL()
    {

        //APN简单推送
//        $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
//        $template = new IGtAPNTemplate();
//        $apn = new IGtAPNPayload();
//        $alertmsg=new SimpleAlertMsg();
//        $alertmsg->alertMsg="";
//        $apn->alertMsg=$alertmsg;
////        $apn->badge=2;
////        $apn->sound="";
//        $apn->add_customMsg("payload","payload");
//        $apn->contentAvailable=1;
//        $apn->category="ACTIONABLE";
//        $template->set_apnInfo($apn);
//        $message = new IGtSingleMessage();

        //APN高级推送
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $template = new \IGtAPNTemplate();
        $apn = new \IGeTui\IGtAPNPayload();
//        $alertmsg=new DictionaryAlertMsg();
//        $alertmsg->body="body";
//        $alertmsg->actionLocKey="ActionLockey";
//        $alertmsg->locKey="LocKey";
//        $alertmsg->locArgs=array("locargs");
//        $alertmsg->launchImage="launchimage";
////        IOS8.2 支持
//        $alertmsg->title="Title";
//        $alertmsg->titleLocKey="TitleLocKey";
//        $alertmsg->titleLocArgs=array("TitleLocArg");
//        $apn->alertMsg=$alertmsg;

//        $apn->badge=7;
//        $apn->sound="com.gexin.ios.silence";
        $apn->add_customMsg("payload", "payload");
//        $apn->contentAvailable=1;
//        $apn->category="ACTIONABLE";
        $template->set_apnInfo($apn);
        $message = new \IGtSingleMessage();

        //PushApn老方式传参
//    $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
//    $template = new IGtAPNTemplate();
//    $template->set_pushInfo("", 4, "", "", "", "", "", "");
//    $message = new IGtSingleMessage();

        //多个用户推送接口
        putenv("needDetails=true");
        $listmessage = new \IGtListMessage();
        $listmessage->set_data($template);
        $contentId = $igt->getAPNContentId(APPID, $listmessage);
        //$deviceTokenList = array("3337de7aa297065657c087a041d28b3c90c9ed51bdc37c58e8d13ced523f5f5f");
        $deviceTokenList = array(DEVICETOKEN);
        $ret = $igt->pushAPNMessageToList(APPID, $contentId, $deviceTokenList);
        return $ret;
    }

//用户状态查询
    public function getUserStatus()
    {
        $CID = I_POST('cid');


        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);

        $rep = $igt->getClientIdStatus(APPID, $CID);
        return $rep;
    }

//推送任务停止
    public function stoptask()
    {

        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $igt->stop("OSA-1127_QYZyBzTPWz5ioFAixENzs3");
    }

//通过服务端设置ClientId的标签
    public function setTag()
    {
        $CID = I_POST('cid');
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $tagList = array('', '中文', 'English');
        $rep = $igt->setClientTag(APPID, $CID, $tagList);
        return $rep;
    }

    public function getUserTags()
    {
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $rep = $igt->getUserTags(APPID, CID);
        //$rep.connect();
        return $rep;
    }


//
//服务端推送接口，支持三个接口推送
//1.PushMessageToSingle接口：支持对单个用户进行推送
//2.PushMessageToList接口：支持对多个用户进行推送，建议为50个用户
//3.pushMessageToApp接口：对单个应用下的所有用户进行推送，可根据省份，标签，机型过滤推送
//

//单推接口
    public function pushMessageToSingle($templateType,$data)
    {
        //$igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
        $igt = new \IGeTui(NULL, APPKEY, MASTERSECRET, false);

        //消息模版：
        // 1.TransmissionTemplate:透传功能模板
        // 2.LinkTemplate:通知打开链接功能模板
        // 3.NotificationTemplate：通知透传功能模板
        // 4.NotyPopLoadTemplate：通知弹框下载功能模板

//    	$template = IGtNotyPopLoadTemplateDemo();
//    	$template = IGtLinkTemplateDemo();
//    	$template = IGtNotificationTemplateDemo();
//      $template =new \IGtTransmissionTemplate();

        switch ($templateType) {
            case '1':
                $notyTitle=$data['title'];//通知栏标题
                $notyContent =$data['message'];//通知栏内容
                $notyIcon ='';//通知栏logo
                $popTitle ='';//弹框标题
                $popContent =$data['content'];//弹框内容
                $popImage ='';//弹框图片
                $popButton1 ='';//左键
                $popButton2 ='';//右键
                $loadIcon ='';//下载框图片
                $loadTitle ='';//下载框图片
                $loadUrl ='';//下载框图片
                $template = $this->IGtNotyPopLoadTemplate($notyTitle, $notyContent, $notyIcon, $isBelled = true, $isVibrationed = true, $isCleared = true, $popTitle, $popContent, $popImage, $popButton1, $popButton2, $loadIcon, $loadTitle, $loadUrl, $isAutoInstall = false, $isActived = true);
                break;
            case '2':
                $title ='';
                $text ='';
                $logo ='';
                $url ='';
                $template = $this->IGtLinkTemplate($title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true, $url);

                break;
            case '3':
                $transmissionContent =$data['content'];
                $title =$data['title'];
                $text =$data['message'];
                $logo ='';
                $template = $this->IGtNotificationTemplate($transmissionType = '1', $transmissionContent, $title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true);
                break;
            case '4':
                $transmissionContent =$data;
                $template = $this->IGtTransmissionTemplate($transmissionType = '1', $transmissionContent);

                break;
        }

        //个推信息体
        $message = new \IGtSingleMessage();

        $message->set_isOffline(true);//是否离线
        $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间
        $message->set_data($template);//设置推送消息类型
//	$message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送
        //接收方
        $target = new \IGtTarget();
        $target->set_appId(APPID);

        foreach ($data['cids'] as $c) {
            $target->set_clientId($c);
        }
//    $target->set_alias(Alias);


        try {
            $rep = $igt->pushMessageToSingle($message, $target);
            return $rep;

        } catch (\RequestException  $e) {
            $requstId = $e . getRequestId();
            $rep = $igt->pushMessageToSingle($message, $target, $requstId);
            return $rep;
        }

    }

    public function pushMessageToSingleBatch($templateType,$data)
    {
        putenv("gexin_pushSingleBatch_needAsync=false");

        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        $batch = new \IGtBatch(APPKEY, $igt);
        $batch->setApiUrl(HOST);
        $CID = I_POST('cid');
        //$igt->connect();
        //消息模版：
        // 1.TransmissionTemplate:透传功能模板
        // 2.LinkTemplate:通知打开链接功能模板
        // 3.NotificationTemplate：通知透传功能模板
        // 4.NotyPopLoadTemplate：通知弹框下载功能模板

        //$template = IGtNotyPopLoadTemplateDemo();
        //$template = IGtLinkTemplateDemo();
        //$template = IGtNotificationTemplateDemo();
        switch ($templateType) {
            case '1':
                $notyTitle=$data['title'];//通知栏标题
                $notyContent =$data['message'];//通知栏内容
                $notyIcon ='';//通知栏logo
                $popTitle ='';//弹框标题
                $popContent =$data['content'];//弹框内容
                $popImage ='';//弹框图片
                $popButton1 ='继续';//左键
                $popButton2 ='关闭';//右键
                $loadIcon ='';//下载框图片
                $loadTitle ='';//下载框图片
                $loadUrl ='';//下载框图片
                $template = $this->IGtNotyPopLoadTemplate($notyTitle, $notyContent, $notyIcon, $isBelled = true, $isVibrationed = true, $isCleared = true, $popTitle, $popContent, $popImage, $popButton1, $popButton2, $loadIcon, $loadTitle, $loadUrl, $isAutoInstall = false, $isActived = true);

                break;
            case '2':
                $title =$data['title'];
                $text =$data['message'];
                $logo ='';
                $url ='';
                $template = $this->IGtLinkTemplate($title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true, $url);

                break;
            case '3':
                $transmissionContent =$data['content'];
                $title =$data['title'];
                $text =$data['message'];
                $logo ='';
                $template = $this->IGtNotificationTemplate($transmissionType = '1', $transmissionContent, $title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true);

                break;
            case '4':
                $transmissionContent =$data['content'];
                $template = $this->IGtTransmissionTemplate($transmissionType = '1', $transmissionContent);

                break;
        }

        //个推信息体
        $message = new \IGtSingleMessage();
        $message->set_isOffline(true);//是否离线
        $message->set_offlineExpireTime(12 * 1000 * 3600);//离线时间
        $message->set_data($template);//设置推送消息类型
//      $message->set_PushNetWorkType(1);//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送

        $target = new \IGtTarget();
        $target->set_appId(APPID);
        $target->set_clientId($CID);
        $batch->add($message, $target);
        try {
            $rep = $batch->submit();
            return $rep;
        } catch (\Exception $e) {
            $rep = $batch->retry();
            return $rep;
        }
    }

//多推接口
    function pushMessageToList($templateType,$data)
    {
        putenv("gexin_pushList_needDetails=true");
        putenv("gexin_pushList_needAsync=true");
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
        //消息模版：
        // 1.TransmissionTemplate:透传功能模板
        // 2.LinkTemplate:通知打开链接功能模板
        // 3.NotificationTemplate：通知透传功能模板
        // 4.NotyPopLoadTemplate：通知弹框下载功能模板

        switch ($templateType) {
            case '1':
                $notyTitle=$data['title'];//通知栏标题
                $notyContent =$data['message'];//通知栏内容
                $notyIcon ='';//通知栏logo
                $popTitle ='';//弹框标题
                $popContent =$data['content'];//弹框内容
                $popImage ='';//弹框图片
                $popButton1 ='确定';//左键
                $popButton2 ='取消';//右键
                $loadIcon ='';//下载框图片
                $loadTitle ='';//下载框图片
                $loadUrl ='';//下载框图片
                $template = $this->IGtNotyPopLoadTemplate($notyTitle, $notyContent, $notyIcon, $isBelled = true, $isVibrationed = true, $isCleared = true, $popTitle, $popContent, $popImage, $popButton1, $popButton2, $loadIcon, $loadTitle, $loadUrl, $isAutoInstall = false, $isActived = true);

                break;
            case '2':
                $title ='';
                $text ='';
                $logo ='';
                $url ='';
                $template = $this->IGtLinkTemplate($title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true, $url);
                break;
            case '3':

                $transmissionContent =$data['content'];
                $title =$data['title'];
                $text =$data['message'];
                $logo ='';
                $template = $this->IGtNotificationTemplate($transmissionType = '1', $transmissionContent, $title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true);
                break;
            case '4':

                $transmissionContent =$data;
                $template = $this->IGtTransmissionTemplate($transmissionType = '1', $transmissionContent);
                break;
        }
        //$template = IGtNotyPopLoadTemplateDemo();
        //$template = IGtLinkTemplateDemo();
        //$template = IGtNotificationTemplateDemo();

        //个推信息体
        $message = new \IGtListMessage();
        $message->set_isOffline(true);//是否离线
        $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间
        $message->set_data($template);//设置推送消息类型
//    $message->set_PushNetWorkType(1);	//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送
//    $contentId = $igt->getContentId($message);
        $contentId = $igt->getContentId($message, "toList任务别名功能");    //根据TaskId设置组名，支持下划线，中文，英文，数字

        //接收方1
        $target1 = new \IGtTarget();
        $target1->set_appId(APPID);


        foreach ($data['cids'] as $c) {
            $target1->set_clientId($c);
            $targetList[] = $target1;
            $rep = $igt->pushMessageToList($contentId, $targetList);
        }


//    $target1->set_alias(Alias);



        return $rep;
    }

//群推接口
    function pushMessageToApp($templateType,$data)
    {
        $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);

        switch ($templateType) {
            case '1':
                $notyTitle=$data['title'];//通知栏标题
                $notyContent =$data['message'];//通知栏内容
                $notyIcon ='';//通知栏logo
                $popTitle ='';//弹框标题
                $popContent =$data['content'];//弹框内容
                $popImage ='';//弹框图片
                $popButton1 ='确定';//左键
                $popButton2 ='取消';//右键
                $loadIcon ='';//下载框图片
                $loadTitle ='';//下载框图片
                $loadUrl ='';//下载框图片
                $template = $this->IGtNotyPopLoadTemplate($notyTitle, $notyContent, $notyIcon, $isBelled = true, $isVibrationed = true, $isCleared = true, $popTitle, $popContent, $popImage, $popButton1, $popButton2, $loadIcon, $loadTitle, $loadUrl, $isAutoInstall = false, $isActived = true);

                break;
            case '2':
                $title ='';
                $text ='';
                $logo ='';
                $url ='';
                $template = $this->IGtLinkTemplate($title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true, $url);
                break;
            case '3':
                $transmissionContent =$data['content'];
                $title =$data['title'];
                $text =$data['message'];
                $logo ='';
                $template = $this->IGtNotificationTemplate($transmissionType = '1', $transmissionContent, $title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true);
                break;
            case '4':
                $transmissionContent =$data;
                $template = $this->IGtTransmissionTemplate($transmissionType = '1', $transmissionContent);
                break;
        }
        //个推信息体
        //基于应用消息体
        $message = new \IGtAppMessage();
        $message->set_isOffline(true);
        $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒，例，两个小时离线为3600*1000*2
        $message->set_data($template);

        $appIdList = array(APPID);
        $phoneTypeList = array('ANDROID');
        $provinceList = array('浙江');
        $tagList = array('haha');
        //用户属性
        //$age = array("0000", "0010");


        //$cdt = new AppConditions();
        // $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList);
        // $cdt->addCondition(AppConditions::REGION, $provinceList);
        //$cdt->addCondition(AppConditions::TAG, $tagList);
        //$cdt->addCondition("age", $age);

        $message->set_appIdList($appIdList);
        //$message->set_conditions($cdt->getCondition());

        $rep = $igt->pushMessageToApp($message, "任务组名");
        return $rep;
    }

//所有推送接口均支持四个消息模板，依次为通知弹框下载模板，通知链接模板，通知透传模板，透传模板
//注：IOS离线推送需通过APN进行转发，需填写pushInfo字段，目前仅不支持通知弹框下载功能

    function IGtNotyPopLoadTemplate($notyTitle, $notyContent, $notyIcon, $isBelled = true, $isVibrationed = true, $isCleared = true, $popTitle, $popContent, $popImage, $popButton1, $popButton2, $loadIcon, $loadTitle, $loadUrl, $isAutoInstall = false, $isActived = true)
    {

        $template = new \IGtNotyPopLoadTemplate();

        $template->set_appId(APPID);//应用appid
        $template->set_appkey(APPKEY);//应用appkey
        //通知栏
        $template->set_notyTitle($notyTitle);//通知栏标题
        $template->set_notyContent($notyContent);//通知栏内容
        $template->set_notyIcon($notyIcon);//通知栏logo
        $template->set_isBelled($isBelled);//是否响铃
        $template->set_isVibrationed($isVibrationed);//是否震动
        $template->set_isCleared($isCleared);//通知栏是否可清除
        //弹框
        $template->set_popTitle($popTitle);//弹框标题
        $template->set_popContent($popContent);//弹框内容
        $template->set_popImage($popImage);//弹框图片
        $template->set_popButton1($popButton1);//左键
        $template->set_popButton2($popButton2);//右键
        //下载
        $template->set_loadIcon($loadIcon);//下载框图片
        $template->set_loadTitle($loadTitle);//下载框标题
        $template->set_loadUrl($loadUrl);//下载框地址
        $template->set_isAutoInstall($isAutoInstall);
        $template->set_isActived($isActived);
        //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息

        return $template;
    }

    function IGtLinkTemplate($title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true, $url)
    {
        $template = new \IGtLinkTemplate();
        $template->set_appId(APPID);//应用appid
        $template->set_appkey(APPKEY);//应用appkey
        $template->set_title($title);//通知栏标题
        $template->set_text($text);//通知栏内容
        $template->set_logo($logo);//通知栏logo
        $template->set_isRing($isRing);//是否响铃
        $template->set_isVibrate($isVibrate);//是否震动
        $template->set_isClearable($isClearable);//通知栏是否可清除
        $template->set_url($url);//打开连接地址
        //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
        //iOS推送需要设置的pushInfo字段
//        $apn = new IGtAPNPayload();
//        $apn->alertMsg = "alertMsg";
//        $apn->badge = 11;
//        $apn->actionLocKey = "启动";
//    //        $apn->category = "ACTIONABLE";
//    //        $apn->contentAvailable = 1;
//        $apn->locKey = "通知栏内容";
//        $apn->title = "通知栏标题";
//        $apn->titleLocArgs = array("titleLocArgs");
//        $apn->titleLocKey = "通知栏标题";
//        $apn->body = "body";
//        $apn->customMsg = array("payload"=>"payload");
//        $apn->launchImage = "launchImage";
//        $apn->locArgs = array("locArgs");
//
//        $apn->sound=("test1.wav");;
//        $template->set_apnInfo($apn);
        return $template;
    }

    function IGtNotificationTemplate($transmissionType = '1', $transmissionContent, $title, $text, $logo, $isRing = true, $isVibrate = true, $isClearable = true)
    {

        $template = new \IGtNotificationTemplate();
        $template->set_appId(APPID);//应用appid
        $template->set_appkey(APPKEY);//应用appkey
        $template->set_transmissionType($transmissionType);//透传消息类型 int
        $template->set_transmissionContent($transmissionContent);//透传内容
        $template->set_title($title);//通知栏标题
        $template->set_text($text);//通知栏内容
        $template->set_logo($logo);//通知栏logo
        $template->set_isRing($isRing);//是否响铃
        $template->set_isVibrate($isVibrate);//是否震动
        $template->set_isClearable($isClearable);//通知栏是否可清除
        //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
        //iOS推送需要设置的pushInfo字段
//        $apn = new IGtAPNPayload();
//        $apn->alertMsg = "alertMsg";
//        $apn->badge = 11;
//        $apn->actionLocKey = "启动";
//    //        $apn->category = "ACTIONABLE";
//    //        $apn->contentAvailable = 1;
//        $apn->locKey = "通知栏内容";
//        $apn->title = "通知栏标题";
//        $apn->titleLocArgs = array("titleLocArgs");
//        $apn->titleLocKey = "通知栏标题";
//        $apn->body = "body";
//        $apn->customMsg = array("payload"=>"payload");
//        $apn->launchImage = "launchImage";
//        $apn->locArgs = array("locArgs");
//
//        $apn->sound=("test1.wav");;
//        $template->set_apnInfo($apn);
        return $template;
    }

    function IGtTransmissionTemplate($transmissionType = '1', $transmissionContent)
    {
        $template = new \IGtTransmissionTemplate();
        $template->set_appId(APPID);//应用appid
        $template->set_appkey(APPKEY);//应用appkey
        $template->set_transmissionType($transmissionType);//透传消息类型
        $template->set_transmissionContent($transmissionContent);//透传内容


        //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
        //APN简单推送
//        $template = new IGtAPNTemplate();
//        $apn = new IGtAPNPayload();
//        $alertmsg=new SimpleAlertMsg();
//        $alertmsg->alertMsg="";
//        $apn->alertMsg=$alertmsg;
////        $apn->badge=2;
////      $apn->sound="";
//        $apn->add_customMsg("payload","payload");
//        $apn->contentAvailable=1;
//        $apn->category="ACTIONABLE";
//        $template->set_apnInfo($apn);
//        $message = new IGtSingleMessage();

        //APN高级推送
//        $apn = new \IGtAPNPayload();
//        $alertmsg=new \DictionaryAlertMsg();
//        $alertmsg->body="body";
//        $alertmsg->actionLocKey="ActionLockey";
//        $alertmsg->locKey="LocKey";
//        $alertmsg->locArgs=array("locargs");
//        $alertmsg->launchImage="launchimage";
//        IOS8.2 支持
//        $alertmsg->title="Title";
//        $alertmsg->titleLocKey="TitleLocKey";
//        $alertmsg->titleLocArgs=array("TitleLocArg");
//
//        $apn->alertMsg=$alertmsg;
//        $apn->badge=7;
//        $apn->sound="";
//        $apn->add_customMsg("payload","payload");
//        $apn->contentAvailable=1;
//        $apn->category="ACTIONABLE";
//        $template->set_apnInfo($apn);

        //PushApn老方式传参
//    $template = new IGtAPNTemplate();
//          $template->set_pushInfo("", 10, "", "com.gexin.ios.silence", "", "", "", "");

        return $template;
    }


}